package com.hansming.bss.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern; 

/**
 * 注册中要用到的邮箱格式和电话格式的验证方法封装类
 */
public class RegisterCheck {
	 /**
     * 验证输入的邮箱格式是否符合
     * @param String email
     * @return boolean
     */
	public static boolean emailFormat(String email){
        boolean tag = true;
        final String pattern1 = "^([a-z0-9A-Z]+[-|//.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?//.)+[a-zA-Z]{2,}$";
        final Pattern pattern = Pattern.compile(pattern1);
        final Matcher mat = pattern.matcher(email);
        if (!mat.find()) {
            tag = false;
        }
        return tag;
    }
	
	/**
	 * 验证是否是正确的手机格式
	 * @param String phone
	 * @return boolean
	 */
	public static boolean checkMobile(String phone){
		boolean tag = true;
        final String pattern1 = "^1[3|4|5|7|8][0-9]\\d{4,8}$";
        final Pattern pattern = Pattern.compile(pattern1);
        final Matcher mat = pattern.matcher(phone);
        if (!mat.find()) {
            tag = false;
        }
        return tag;
	}
}
